package cn.dida.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.dida.dao.BrandDao;
import cn.dida.model.Brand;
import cn.dida.model.Pageable;
import cn.dida.service.BrandService;
/**
 * 品牌管理 业务层接口实现类
 * @author weiwei
 *
 */
@Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private BrandDao brandDao;

    @Override
    public Pageable<Brand> queryBrand(Integer companyId, String keyword, Integer state, int page) {
        return brandDao.query(companyId, keyword, state, page);
    }

    @Override
    public List<Brand> queryBrand(Integer companyId, Integer state) {
        return brandDao.query(companyId, state);
    }
    @Transactional
    @Override
    public Boolean insertBrand(Brand brand) {
        return brandDao.insert(brand) == 1;
    }
    @Transactional
    @Override
    public Boolean updateBrand(Brand brand) {
        return brandDao.update(brand) == 1;
    }

    @Override
    public Brand getBrand(Integer companyId, Integer id) {
        return brandDao.get(companyId, id);
    }

    @Override
    public Brand getBrandByName(Integer companyId, String name) {
        return brandDao.getByName(companyId, name);
    }
    @Transactional
    @Override
    public Boolean deleteBrand(Integer companyId, Integer id) {
        return brandDao.delete(companyId, id) == 1;
    }
}
